<?php

namespace app\admin\widget;

/**
 * 书库中的一些常用组件 widget
 */

class Book
{
	public $pubparam;

	public function __construct() {
		$pubparam = [
			"book_id" => input('param.book_id'),
			"cate_type" => input('param.cate_type'),
		];
		$this->pubparam = http_build_query($pubparam);
    }

	//书名
	public function book($book_id = 47) {
		$map = [];
		$books    = db('ads_material_book')
			->field("id,name as sex, title as name")
			->where($map)->order('sex desc,sort asc,id asc')
			->limit(1000)
			->select();
		// dump($books);exit;
		$currurl = url();
		$view   = new \think\View();
		$data = [
			'books'   => $books,
			"book_id" => $book_id,
			'currurl' => $currurl,
			'pubparam' => $this->pubparam
		];
		$view->assign($data);
		$template = 'book';
		return $view->fetch('admin@widget/book/' . $template);
	}

	//分类
	public function cate($cate_type = 'summary') {
		$cates = [
			'summary' => '概述(未开发)',
			'book'    => '文本(未开发)',
			'version' => '版本(未开发)',
			'datas' => '数据(未开发)',
			'baidu_text' => '百度文案',
			'douyin_text' => '抖音文案',
			'weibo_text' => '微博文案',
			'img' => '图片',
			'video' => '视频',
			'bgm' => '音频',
		];
		$currurl = url();
		$view   = new \think\View();
		$data = [
			'cates'   => $cates,
			"cate_type" => $cate_type,
			'currurl' => $currurl,
			'pubparam' => $this->pubparam
		];
		$view->assign($data);
		$template = 'cate';
		return $view->fetch('admin@widget/book/' . $template);
	}
}
